//
//  XLStausOrginaView.swift
//  WeiBo
//
//  Created by macbook on 16/10/19.
//  Copyright © 2016年 buWangChuXing. All rights reserved.
//

import UIKit
private let OriginalMargin: CGFloat = 10
class XLStausOrginaView: UIView {

    //设置数据
    var status:XLStatus?{
    
        didSet{
        
            //用户名称
            nameLabel.text = status?.user?.name
            iconImage.sd_setImageWithURL(NSURL(string: (status?.user?.profile_image_url)!), placeholderImage: UIImage(named: "avatar_default_big"))
            
            contentLabel.text = status?.text
            //Vip等级vip
            expiredImageView.image = status?.user?.mbrankImage
            
            //认证varifiedImage
            vipImageView.image = status?.user?.varifiedImage
        }
    }
    
     
    
    
    override init(frame: CGRect) {
        super.init(frame: frame)
    
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private func setupUI()
    {
        //添加
        addSubview(iconImage)
        addSubview(nameLabel)
        addSubview(expiredImageView)
        addSubview(timelabel)
        addSubview(sourceLabel)
        addSubview(vipImageView)
        addSubview(contentLabel)
        
        //头像
        iconImage.snp_makeConstraints { (make) in
            
            make.top.left.equalTo(self).offset(OriginalMargin)
            make.size.equalTo(CGSize(width: 35, height: 35))
        }
        
        //名称
        nameLabel.snp_makeConstraints { (make) in
            
            make.top.equalTo(iconImage.snp_top)
            make.left.equalTo(iconImage.snp_right).offset(OriginalMargin)
        }
        
        
        //vip
        expiredImageView.snp_makeConstraints { (make) in
            
            make.centerY.equalTo(nameLabel.snp_centerY)
            make.left.equalTo(nameLabel.snp_right).offset(OriginalMargin)
        }
        
        //发布微博时间
        timelabel.snp_makeConstraints { (make) in
            
            make.left.equalTo(nameLabel.snp_left)
            make.bottom.equalTo(iconImage.snp_bottom)
        }
        
        //来源
        sourceLabel.snp_makeConstraints { (make) in
            
            make.centerY.equalTo(timelabel.snp_centerY)
            make.left.equalTo(timelabel.snp_right).offset(OriginalMargin)
        }
        
        //vip认证
        vipImageView.snp_makeConstraints { (make) in
            
            make.centerY.equalTo(iconImage.snp_bottom)
            make.centerX.equalTo(iconImage.snp_right)
        }
        
        //内容显示
        contentLabel.snp_makeConstraints { (make) in
            
            make.top.equalTo(iconImage.snp_bottom).offset(OriginalMargin)
            make.left.equalTo(iconImage.snp_left)
            
        }
        
        //约束自己
        self.snp_remakeConstraints { (make) in
            
            make.bottom.equalTo(contentLabel.snp_bottom).offset(OriginalMargin)
        }
        

        
        
        
        //设置临时数据
        nameLabel.text = "姓名"
        timelabel.text = "时间"
        sourceLabel.text = "来自磊哥的微博"
        contentLabel.text = "asdjkf花生的贺卡啊哈哈圣诞节开发阿斯顿和可减肥爱看见了好地方 啊是尽快发货氨基酸的合法及的地方阿道夫多撒谎放假哈看似简单后付款就爱上的疯狂就asdjkf花生的贺卡啊哈哈圣诞节开发阿斯顿和可减肥爱看见了好地方 啊是尽快发货氨基酸的合法及的地方阿道夫多撒谎放假哈看似简单后付款就爱上的疯狂就asdjkf花生的贺卡啊哈哈圣诞节开发阿斯顿和可减肥爱看见了好地方 啊是尽快发货氨基酸的合法及的地方阿道夫多撒谎放假哈看似简单后付款就爱上的疯狂就asdjkf花生的贺卡啊哈哈圣诞节开发阿斯顿和可减肥爱看见了好地方 啊是尽快发货氨基酸的合法及的地方阿道夫多撒谎放假哈看似简单后付款就爱上的疯狂就asdjkf花生的贺卡啊哈哈圣诞节开发阿斯顿和可减肥爱看见了好地方 啊是尽快发货氨基酸的合法及的地方阿道夫多撒谎放假哈看似简单后付款就爱上的疯狂就"
        
    }
    
    //懒加载
    //头像
    private lazy var iconImage:UIImageView = UIImageView(imageName: "avatar_default_big")
    
    //名字
    private lazy var nameLabel:UILabel = UILabel(textColor: UIColor.darkGrayColor(), textFont: 15)
    
    //用户等级
    private lazy var expiredImageView:UIImageView = UIImageView(imageName: "common_icon_membership_expired")
    
    //时间
    private lazy var timelabel:UILabel = UILabel(textColor: ThemeColor, textFont: 10)
    
    //来源
    private lazy var sourceLabel:UILabel = UILabel(textColor: UIColor.grayColor(), textFont: 10)
    
    //vip
    private lazy var vipImageView:UIImageView = UIImageView(imageName: "avatar_vgirl")

    //内容显示的label
    private lazy var contentLabel:UILabel = UILabel(textColor: UIColor.blackColor(), textFont: 15, labelWith: KScreenW - 2 * OriginalMargin)
    
    
}








